/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Feb 23, 2012  11:16:25 AM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : sap.business.commons
 * File Name : SynchroOutAbstract.java
 * TODO
 */
package sap.business.commons;

import java.util.List;

import javax.persistence.EntityManager;

import jpa.entitys.synchro.staging.SyncAttachFile;

import org.apache.log4j.Logger;
import sap.jco.client.Connection;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoStructure;
import com.sap.conn.jco.JCoTable;
/**
 * @author chatree
 *
 */
public abstract class SynchroOutAbstract implements SynchroOutImplement {
	
	
	private static final Logger log = Logger.getLogger(SynchroOutAbstract.class);
	
	protected String sap_bapi;
	protected String sap_table;
	protected String sap_structure;
	protected String sap_table_return;
	
	//Jpa
	protected EntityManager emSynchro;	
	
	//Jpa
	protected EntityManager emPromis;
	
	//Sap 
	protected Connection jco_conn;
	
	
	protected EntityManager CreateEmSynchro() throws Exception
	{
		EntityManager emSynchro = new jpa.service.common.SessionEntityManager().CreatedEntityManager();
		
		return emSynchro;
	}
	
	protected EntityManager CreateEmPromis() throws Exception
	{
		EntityManager emPromis = new jpa.service.promis.common.SessionEntityManager().CreatedEntityManager();
		
		return emPromis;		
	}
	
	/**
	 * (Javadoc)
	 * @see sap.business.commons.SynchroOutImplement#CallbackMessageFromSap(com.sap.conn.jco.JCoTable)
	 * Date =Nov 12, 2013 : 11:50:10 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	public void CallbackMessageFromSap(JCoTable jcoTable_return) throws Exception {
	
		
	}
	
	/**
	 * (Javadoc)
	 * @see sap.business.commons.SynchroOutImplement#SynchroToSap(com.sap.conn.jco.JCoFunction, com.sap.conn.jco.JCoTable, java.util.List)
	 * Date =Nov 12, 2013 : 11:50:21 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	public void SynchroToSap(JCoFunction jcoFunction, JCoTable jcoTable, List<?> value_list) throws Exception {
		jcoFunction.execute(jco_conn.getJCoConnection());
		System.out.println("Sending to SAP ");
	}
	
	public void SynchroToSap(JCoFunction jcoFunction, JCoTable jcoTable, JCoTable jcoTable1, List<?> value_list, List<SyncAttachFile> attchList) throws Exception {
		jcoFunction.execute(jco_conn.getJCoConnection());
		System.out.println("Sending to SAP ");
	}
	
	/**
	 * (Javadoc)
	 * @see sap.business.commons.SynchroOutImplement#SynchroToSap(com.sap.conn.jco.JCoFunction, com.sap.conn.jco.JCoStructure, java.util.List)
	 * Date =Nov 12, 2013 : 11:50:29 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	public void SynchroToSap(JCoFunction jcoFunction, JCoStructure jCoStructure, List<?> value_list) throws Exception {
		jcoFunction.execute(jco_conn.getJCoConnection());
		System.out.println("Sending to SAP ");
	}
	
	
	/**
	 * (Javadoc)
	 * @see sap.business.commons.SynchroOutImplement#SynchroToSap(com.sap.conn.jco.JCoFunction, com.sap.conn.jco.JCoTable, com.sap.conn.jco.JCoStructure, java.util.List)
	 * Date =Nov 12, 2013 : 11:50:34 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	public void SynchroToSap(JCoFunction jcoFunction, JCoTable jcoTable, JCoStructure jCoStructure, List<?> value_list) throws Exception {
		jcoFunction.execute(jco_conn.getJCoConnection());
		System.out.println("Sending to SAP ");
	}

}
